#include <map>
#include <QMutex>
#include "clcomlog.h"
#include "RealLogEx.h"

static map<string, CRealLogEx*> s_mapInstances;
static QMutex s_lock;

CLComLog* CLComLog::GetLogInstance(const char* keystr)
{
    CRealLogEx* pInstance = NULL;
    s_lock.lock();

    auto it = s_mapInstances.find(keystr);
    if (it == s_mapInstances.end())
    {
        pInstance = new CRealLogEx;

        s_mapInstances[keystr] = pInstance;
    }
    else
    {
        pInstance = it->second;
    }
    s_lock.unlock();

    return pInstance;
}
